cd ""
* use "data_figure_5.dta", replace 
import delimited "data_figure_5.txt", clear 
format date %td
gen coef_sales_all=.
gen sd_sales_all=.
bys id2: egen me=mean(debits2)

tsset id2 a

gen dld2=d.ld2

bys id2: egen aa=max(dld2)
bys id2: egen ab=min(dld2)
tsset id2 a

 char a[omit] 0
 xi: reghdfe ld2 i.a*radio c.a#c.urban c.a#c.d_old  c.a#c.black   if  aa<1.0 & ab>-1.0   , absorb(id2 ss#date ff#date ss#a ff#a ) cluster(id2)

matrix A=e(b)
matrix B=e(V)

forval i=12(1)16 {

replace coef_sales_all=A[1,`i']  if a==-12-5+`i'
replace sd_sales_all=sqrt(B[`i',`i'])  if a==-12-5+`i'


}

replace coef_sales_all=0 if a==0
replace sd_sales_all=0 if a==0
forval i=17(1)21{


replace coef_sales_all=A[1,`i']  if a==-16+`i'
replace sd_sales_all=sqrt(B[`i',`i'])  if a==-16+`i'


}



gen upperb_sales_all=coef_sales_all+1.65*sd_sales_all
gen lowerb_sales_all=coef_sales_all-1.65*sd_sales_all

 
 gen upperb_sales5_all=coef_sales+1.96*sd_sales
gen lowerb_sales5_all=coef_sales-1.96*sd_sales

*sort date
graph twoway   (rspike lowerb_sales5_all upperb_sales5_all a, color(gs12) mcolor(0)) (rcap lowerb_sales_all upperb_sales_all a, color(gs0) lwidth(medium) )  ///
 (scatter coef_sales_all a, color(gs0))   if city==1  , legend( label(1 "90%")  label(3 "Coefficient") label(2 "95%")  rows(1) order(3 2 1 ) ) ///
 ytitle(Log Debits) xtitle("") yline(0, lcolor(black)) xline(0, lcolor(black)) name(b7, replace) ///
  graphregion(color(white))  ylabel(-0.4(0.1)0.4) xsc(r(-5  5)) xlabel(-5(1)5)  ysc(r(-0.4 0.4))
